package io.renren.modules.app.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import io.renren.common.utils.PageUtils;
import io.renren.modules.app.entity.AppMenuEntity;
import io.renren.modules.app.service.AppMenuService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Program: renren-fast
 * @Package: io.renren.modules.mynj.service.impl
 * @ClassName: AppMenuServiceImpl
 * @Description: AppMenu服务接口实现类
 * @Author: ShenPengPeng
 * @CreateDate: 2018-11-03 13:55
 * @Version: 1.0
 */
@Service("appMenuService")
public class AppMenuServiceImpl implements AppMenuService {
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        Page<AppMenuEntity> page = new Page<>();
        List<AppMenuEntity> appMenuEntities = new ArrayList<>();
        AppMenuEntity appMenuEntity = null;
        appMenuEntity = new AppMenuEntity();
        appMenuEntity.setMenuId("1");
        appMenuEntity.setMenuName("积分商城");
        appMenuEntity.setMenuCode("asd");
        appMenuEntity.setMenuUrl("http://49.65.1.134:8081/mshsys/");
        appMenuEntity.setMenuType("H5");
        appMenuEntity.setAscription("城市生活");
        appMenuEntity.setIsVarification("否");
        appMenuEntity.setDeleteFlag("0");
        appMenuEntities.add(appMenuEntity);

        appMenuEntity = new AppMenuEntity();
        appMenuEntity.setMenuId("2");
        appMenuEntity.setMenuName("查违章");
        appMenuEntity.setMenuCode("bvf");
        appMenuEntity.setMenuUrl("http://49.65.1.134:8081/mshsys/");
        appMenuEntity.setMenuType("H5");
        appMenuEntity.setAscription("城市生活");
        appMenuEntity.setIsVarification("否");
        appMenuEntity.setDeleteFlag("1");
        appMenuEntities.add(appMenuEntity);

        appMenuEntity = new AppMenuEntity();
        appMenuEntity.setMenuId("3");
        appMenuEntity.setMenuName("同名查询");
        appMenuEntity.setMenuCode("555");
        appMenuEntity.setMenuUrl("http://49.65.1.134:8081/mshsys/");
        appMenuEntity.setMenuType("H5");
        appMenuEntity.setAscription("我的家园");
        appMenuEntity.setIsVarification("否");
        appMenuEntity.setDeleteFlag("0");
        appMenuEntities.add(appMenuEntity);

        page.setRecords(appMenuEntities);
        page.setTotal(26);

        if("查违章".equals(params.get("appMenuName"))){
            appMenuEntities.remove(0);
            appMenuEntities.remove(1);
            page.setRecords(appMenuEntities);
        };

        return new PageUtils(page);
    }

    @Override
    public void deleteBatch(String[] menuIds) {
        for(String s:menuIds){
            System.out.println(s);
        }


    }

    @Override
    public List<Map<String, String>> getMenuClassifys() {
        List<Map<String, String>> menuClassifys = new ArrayList<>();
        Map<String,String> menuClassify = new HashMap<>();
        menuClassify.put("label","交通");
        menuClassify.put("value","交通");
        menuClassifys.add(menuClassify);
        menuClassify = new HashMap<>();
        menuClassify.put("label","健康");
        menuClassify.put("value","健康");
        menuClassifys.add(menuClassify);
        menuClassify = new HashMap<>();
        menuClassify.put("label","文化");
        menuClassify.put("value","文化");
        menuClassifys.add(menuClassify);
        menuClassify = new HashMap<>();
        menuClassify.put("label","社区");
        menuClassify.put("value","社区");
        menuClassifys.add(menuClassify);
        menuClassify = new HashMap<>();
        menuClassify.put("label","政务");
        menuClassify.put("value","政务");
        menuClassifys.add(menuClassify);
        menuClassify = new HashMap<>();
        menuClassify.put("label","大学生");
        menuClassify.put("value","大学生");
        menuClassifys.add(menuClassify);
        menuClassify = new HashMap<>();
        menuClassify.put("label","财富");
        menuClassify.put("value","财富");
        menuClassifys.add(menuClassify);
        menuClassify = new HashMap<>();
        menuClassify.put("label","公益");
        menuClassify.put("value","公益");
        menuClassifys.add(menuClassify);
        menuClassify = new HashMap<>();
        menuClassify.put("label","其他");
        menuClassify.put("value","其他");
        menuClassifys.add(menuClassify);
        return menuClassifys;
    }

    @Override
    public List<Map<String, Object>> getVersions() {
        List<Map<String,Object>> versions = new ArrayList<>();
        List<Map<String,String>> roles = null;
        Map<String,String> role = null;
        Map<String,Object> version = new HashMap<>();
        version.put("id","1");
        version.put("label","版本1");
        roles = new ArrayList<>();
        role = new HashMap<>();
        role.put("id","1.1");
        role.put("label","角色1");
        roles.add(role);
        role = new HashMap<>();
        role.put("id","1.2");
        role.put("label","角色2");
        roles.add(role);
        version.put("roles",roles);
        versions.add(version);


        version = new HashMap<>();
        version.put("id","2");
        version.put("label","版本2");
        roles = new ArrayList<>();
        role = new HashMap<>();
        role.put("id","2.1");
        role.put("label","角色1");
        roles.add(role);
        role = new HashMap<>();
        role.put("id","2.2");
        role.put("label","角色2");
        roles.add(role);
        version.put("roles",roles);
        versions.add(version);


        version = new HashMap<>();
        version.put("id","3");
        version.put("label","版本3");
        roles = new ArrayList<>();
        role = new HashMap<>();
        role.put("id","3.1");
        role.put("label","角色1");
        roles.add(role);
        role = new HashMap<>();
        role.put("id","3.2");
        role.put("label","角色2");
        roles.add(role);
        version.put("roles",roles);
        versions.add(version);

        return versions;
    }

    @Override
    public AppMenuEntity queryMenuById(String menuId) {
        AppMenuEntity appMenuEntity = null;
        if ("1".equals(menuId)) {
            appMenuEntity = new AppMenuEntity();
            appMenuEntity.setMenuName("积分商城");
            appMenuEntity.setMenuCode("asd");
            appMenuEntity.setMenuUrl("http://49.65.1.134:8081/mshsys/");
            appMenuEntity.setCityAsSortEmentId("财富");
            appMenuEntity.setMenuType("1");
            appMenuEntity.setAscription("1");
            appMenuEntity.setVisitor("1");
            appMenuEntity.setIsVarification("1");
            return appMenuEntity;

        }else if ("2".equals(menuId)){
            appMenuEntity = new AppMenuEntity();
            appMenuEntity.setMenuName("查违章");
            appMenuEntity.setMenuCode("bvf");
            appMenuEntity.setMenuUrl("http://49.65.1.134:8081/mshsys/");
            appMenuEntity.setCityAsSortEmentId("交通");
            appMenuEntity.setMenuType("1");
            appMenuEntity.setAscription("1");
            appMenuEntity.setVisitor("1");
            appMenuEntity.setIsVarification("0");
            return appMenuEntity;
        }

        return null;
    }

    public static  void  main(String[] args){
        System.out.println(new AppMenuServiceImpl().queryMenuById("1"));
    }
}
